﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FourWayClimbingDemo.Chess
{
    /// <summary>
    /// 棋子
    /// </summary>
    public class ChessPiece
    {
        private int _row = -1;  //棋子在棋盘行坐标 0-3  其他值为无效棋子
        private int _col = -1;  //棋子在棋盘的列坐标 0-3  其他值为无效棋子
        private string _tag = ""; //棋子标记

        public ChessPiece(int row,int col,string tag) {
            this._row = row;
            this._col = col;
            this._tag = tag;
        }

        public string Tag
        {
            get { return _tag; }
            set { _tag = value; }  
        }

        /// <summary>
        /// 获取在棋盘的坐标位置
        /// </summary>
        public (int row, int col) GetPosition() {
            return (_row,_col);        
        }

        /// <summary>
        /// 判断该坐标位置是否是自己
        /// </summary>
        public Boolean IsMine(int row,int col) {
            return row == _row && col == _col;
        }

        /// <summary>
        /// 移动位置
        /// </summary>
        public void Move(int row,int col) {
            this._row = row;
            this._col = col;
        }

        /// <summary>
        /// 棋子被吃掉
        /// </summary>
        public void Dead() {
            this._row = -1;
            this._col = -1;
        }

        /// <summary>
        /// 判断棋子是否被吃掉
        /// </summary>
        public Boolean IsDead
        {
            get { return _row <0 || _col <0; }          
        }
    }
}
